{include file='public/head' /}
{include file='public/left' /}
<div class="main" style="padding:10px;">
    <div class="content">
        <span>菜单列表</span>
        <button class="layui-btn  layui-btn-sm" onclick="add()">添加</button>
        <div></div>
    </div>
    <table class="layui-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>标题</th>
            <th>父ID</th>
            <th>控制器</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name='menu' id='menu_v'}
        <tr>
            <td>{$menu_v.id}</td>
            <td>{$menu_v.title}</td>
            <td>{$menu_v.fid}</td>
            <td>{$menu_v.controller}</td>
            <td>{if $menu_v.status==1}开启{else/}关闭{/if}</td>
            <td><button class="layui-btn layui-btn-xs"
                        onclick="edit({$menu_v.id})">修改</button>
                <button class="layui-btn layui-btn-xs layui-btn-danger"
                        onclick="del({$menu_v.id})">删除</button></td>
        </tr>
        {/volist}
        </tbody>
    </table>
</div>
<script type="text/javascript">
    function add(){
        layer.open({
            title: '添加',
            type:2,
            shade:0.3,
            area:['480px','440px'],
            content: '/admin/menu/add'
        });
    }
    function del(id){
        layer.confirm('确定要删除吗？', {
            icon:3,
            btn: ['确定','取消']
        }, function(){
            $.post('/admin/menu/del',{'id':id},function(res){
                if(res.code>0){
                    layer.alert(res.msg,{icon:2});
                }else{
                    layer.msg(res.msg);
                    setTimeout(function(){window.location.reload();},1000);
                }
            },'json');
        });
    }
    function edit(id){
        layer.open({
            title: '修改',
            type:2,
            shade:0.3,
            area:['480px','440px'],
            content: '/admin/menu/edit?id='+id
        });
    }
</script>
{include file='public/bottom' /}